<@master template="/common/master"  title="注册">
<@css href="/css/wx/recruit/dk.css" rel="stylesheet"/>
	<div class="fromDiv1" id="subForm">
	<div class="yytlogo"><@img src="/images/public/logo.png"/></div>
	<ul>
    	<li>
    		<span class="Div-img">
    		<@img src="/images/wx/recruit/login-reg/id.png" alt=""/>
    	</span><input name="tel" type="tel" placeholder="手机号码"></li>
        <li class="Xiu">
        <a href="javascrpt:void(0)" id="showPwd">
                <@img  id="Xiu-img" src="/images/wx/recruit/login-reg/xiugai0.png" alt=""/></a>
        <span class="pass-img">
    		<@img src="/images/wx/recruit/login-reg/password.png" alt=""/>
    	</span><input name="password" id="password"  type="password" placeholder="设置6-16位密码"></li>
    	<li class="Yan">
            <img  id="Yan-img" src="/eascs-o2o-h5/common/getCaptcha" alt=""/>
    		<span class="ver-img">
    		<@img src="/images/wx/recruit/login-reg/tuxing.png" alt=""/>
    	</span><input name="erifyCode" id="erifyCode"  type="text" placeholder="图形验证码">
       	
    </li>
    	<li class="Yan">
    		<a class="DGet" id="verfyBtn" href="javascript:void(0)">立即获取</a>
    		<span class="ver-img">
    		<@img src="/images/wx/recruit/login-reg/phoneY.png" alt=""/>
    	</span><input name="authCode"  type="text" placeholder="短信验证码"></li>
    </ul>
	<a id="SubBtn" href="javascript:void(0)" class="Sbtn" style="margin-bottom:.15rem;">立即注册</a>
	<div class=""><p class="fr c999 mt10">已有账号？<a href="/eascs-o2o-h5/uc/login/index" id="quick">登录</a></div>
	</div>
<div id="showMsgDiv" class="tcTxt1 smDiv" style="display:none;">
    <div class="tcjz"></div>
</div>
</@master>
<script>
	 document.getElementById("showMsgDiv").style.height = document.body.clientHeight + 'px'; 
</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3ab2a83a372d20f084552b836c038302";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<@js>
$(document).ready(function(){
		$('#showPwd').bind('click',function(){
			var typeName = $('#password').attr("type");
			if (typeName == 'password') {
				$('#password').attr("type","text");
				$('#password').css("color","blue");
			} else {
				$('#password').attr("type","password");
				$('#password').css("color","black");
			}
		});
		$('#showMsgDiv').bind('click',function(){
			$('#showMsgDiv').hide();
		});
		$("#Yan-img").bind("click",function(){
		  var img = document.getElementById("Yan-img");  
	       img.src = "/eascs-o2o-h5/common/getCaptcha?rnd=" + Math.random();  
		});
    	$('#verfyBtn').bind("click",function(){
    		if(!validate()) {
    			$("#showMsgDiv").show(1000).delay(1000).fadeOut("hide"); 
				return false;
			}
			 var erifyCode = $("#erifyCode").val();
		  	 $.getJSON("/eascs-o2o-h5/common/checkCaptcha",{captcha:erifyCode},function(result){
				if (result.data == true) {
	    				if (countdown == 60) {
	    					var mobile=$('#subForm input[name="tel"]').val();
	    					$.getJSON("/eascs-o2o-h5/msg/rest/sendAuthCode",{phone:mobile},function(result){
				    			if(result.data.success){
				   					$('#showMsgDiv .tcjz').text("短信已发送成功，请注意查收").parent().show();
				   					$("#showMsgDiv").show(1000).delay(1000).fadeOut("hide"); 
				   					settime();
				   				}else{
				   					$('#showMsgDiv .tcjz').text(result.data.errMsg).parent().show();
				   					$("#showMsgDiv").show(1000).delay(1000).fadeOut("hide"); 
				   				}
				    		});
	    				}
				} else {
					$('#showMsgDiv .tcjz').text("请输入正确的图形验证码").parent().show();
					$("#showMsgDiv").show(1000).delay(1000).fadeOut("hide"); 
					var img = document.getElementById("Yan-img");  
	      			img.src = "/eascs-o2o-h5/common/getCaptcha?rnd=" + Math.random(); 
				}
	    	 });
			
    	});
    	
    	$("#SubBtn").bind("click",function(){
	    	var mobile=$('#subForm input[name="tel"]').val();
	    	var password = $('#subForm input[name="password"]').val();
	    	var authCode = $('#subForm input[name="authCode"]').val();
	    	if(!validate()) {
    			$("#showMsgDiv").show(1000).delay(1000).fadeOut("hide"); 
				return false;
			}
			if (!authCode) {
				$('#showMsgDiv .tcjz').text("请输入短信验证码").parent().show();
				$("#showMsgDiv").show(1000).delay(1000).fadeOut("hide"); 
				return false;
			}
	    	$.getJSON("/eascs-o2o-h5/msg/rest/checkAuthCode",{phone:mobile,authCode:authCode},function(result){
	    		if (result.data.success) {
	    			$.get("/eascs-o2o-h5/uc/rest/register", {'mobile':mobile,'password':password},function(msgResult){
	    				if(msgResult.data.success == true){
				    		window.location.href = "/eascs-o2o-h5/uc/register/success";
				    	}else{
				    		$('#showMsgDiv .tcjz').text(msgResult.data.errMsg).parent().show();
				    		$("#showMsgDiv").show(1000).delay(1000).fadeOut("hide"); 
				    	}	
	    			});
	    		} else {
	    			$('#showMsgDiv .tcjz').text("请输入正确的短信验证码").parent().show();
	    			$("#showMsgDiv").show(1000).delay(1000).fadeOut("hide"); 
	    		}
	    	});
    		
    	});
    	
	});
	    function validate(){
    		var rege=/^(?:13\d|14\d|15\d|17\d|18\d)-?\d{5}(\d{3}|\*{3})$/;
    		var mobile=$('#subForm input[name="tel"]').val();
    		if (!mobile) {
    			$('#showMsgDiv .tcjz').text("请输入手机号码").parent().show();
    			return false;
    		}
    		if(!rege.test(mobile)){
    			$('#showMsgDiv .tcjz').text("请输入正确的手机号码").parent().show();
    			return false;
    		}
  			var password = $('#subForm input[name="password"]').val();
  			if(!password){
    			$('#showMsgDiv .tcjz').text("请输入密码").parent().show();
    			return false;
    		}
    		if(password.length < 6 || password.length > 16 ){
    			$('#showMsgDiv .tcjz').text("请输入6-16位密码").parent().show();
    			return false;
    		}
    		var pwdge = /^[a-zA-Z\d]+$/;
    		if (!pwdge.test(password)) {
    			$('#showMsgDiv .tcjz').text("登录密码只能包含数字与字母").parent().show();
    			return false;
    		} 
 	    	var erifyCode = $("input[name='erifyCode']").val();
	    	if(!erifyCode){
	    		$('#showMsgDiv .tcjz').text("请输入图片验证码").parent().show();
	    		return false;
	    	}   		
    		return true;   	
    	}
		var countdown=60; 
		function settime() { 
			if (countdown == 0) { 
				countdown = 60; 
				$("#verfyBtn").css("color","#007cb8")
				$("#verfyBtn").html("立即获取");
			} else { 
				$("#verfyBtn").css("color","grey")
				$("#verfyBtn").attr("disabled", true); 
				$("#verfyBtn").html("重新发送(" + countdown + "s)");
				countdown--; 
				setTimeout(function() { 
					settime() 
				},1000) 
			} 
		} 
		
</@js> <@jsRender/>
